#ifndef __KEY_H__
#define __KEY_H__

#include "GPIO.h"

#define KEY1 P51
#define KEY2 P52
#define KEY3 P53
#define KEY4 P54

#define UP 1
#define DOWN 0

#define IS_KEY_UP(i) (((key_state >> i) & 1) == UP)
#define IS_KEY_DOWN(i) ((key_state & (1 << i)) == DOWN)
#define SET_KEY_UP(i) (key_state |= (1 << i))
#define SET_KEY_DOWN(i) (key_state &= ~(1 << i))

void KEY_Init(void);
void get_key_state(void (*key_down)(u8 i, u8 key_stat), void (*key_up)(u8 i));


#endif